Learn R Programming

ngram (version 1.1)

ngram Getters: ngram Getters

Description

Some simple "getters" for ngram objects. Necessary since the internal representation is not a native R object.

Usage

## S3 method for class 'ngram':
get.ngrams(ng)

## S3 method for class 'ngram': get.string(ng)

## S3 method for class 'ngram': get.nextwords(ng)

Arguments

ng
An ngram object.

Details

get.ngrams() returns an R vector of all n-grams. get.nextwords() does nothing at the moment; it will be implemented in future releases. getnstring() recovers the input string as an R string.

See Also

ngram

Examples

Run this code
library(ngram)

str <- "A B A C A B B"
ng <- ngram(str)
get.ngrams(ng)

Run the code above in your browser using DataLab